/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Negocio;

import Datos.FacturaClienteDB;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author INGENIERIA
 */
public class FacturaCliente {
        
    Cliente c = new Cliente();
    Factura f = new Factura();

    public Cliente getC() {
        return c;
    }

    public void setC(Cliente c) {
        this.c = c;
    }

    public Factura getF() {
        return f;
    }

    public void setF(Factura f) {
        this.f = f;
    }

    
    
   public void grabar() {
            FacturaClienteDB compraDB = new FacturaClienteDB();
        try {
            compraDB.grabar(this);
        } catch (SQLException ex) {
           // Logger.getLogger(FacturaCliente.class.getName()).log(Level.SEVERE, null, ex);
        }
    }    

    public void eliminar() {
        try {
        FacturaClienteDB compraDB = new FacturaClienteDB();
            compraDB.eliminar(this.f.getId());
        } catch (SQLException ex) {
            Logger.getLogger(Compras.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void buscar() {
        try {
            FacturaCliente aux;
            FacturaClienteDB factCliDB = new FacturaClienteDB();
            aux = factCliDB.buscar(this.f.getId());
            setF(aux.f);
            setC(aux.c);
            
        } catch (SQLException ex) {
        } 
    } 
    
    public void buscarCed() {
        try {
            FacturaCliente aux;
            FacturaClienteDB factCliDB = new FacturaClienteDB();
            aux = factCliDB.buscarCed(this.c.getCedula());
            setF(aux.f);
            setC(aux.c);
            
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "No existe un cliente con esa cedula");
        } 
    } 
    
}